package it.sciuto.greetings.adapters;

import it.sciuto.greetings.R;
import it.sciuto.greetings.activities.ZoomActivity;

import java.util.LinkedList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class BackgroundAdapter extends BaseAdapter {
	private Activity activity;
	private LinkedList<Bitmap> images;

	public BackgroundAdapter(Activity activity, LinkedList<Bitmap> images) {
		this.activity = activity;
		this.images = images;
	}

	public int getCount() {
		return images.size();
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(final int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = vi.inflate(R.layout.background_row, null);
		}

		// Image View Preview
		ImageView iv = (ImageView) convertView.findViewById(R.id.list_preview);
		iv.setImageBitmap(images.get(position));
		// iv.setOnClickListener(new OnClickListener() {
		//
		// public void onClick(View arg0) {
		// // Intent mIntent = new Intent(activity, ZoomActivity.class);
		// // Bundle mBundle = new Bundle();
		// // // mBundle.putString("filename", images.get(position);
		// // mIntent.putExtras(mBundle);
		// // activity.startActivity(mIntent);
		// activity.finish();
		// }
		// });

		return convertView;
	}
}